package com.yudean.esb.cached;

import java.util.List;

/**
 * Cache Interface
 *
 * @author Duan Lei
 * @version 1.0
 */
public interface Cache {

    /**
     * get an object from cache
     *
     * @param key
     * @return the cached object or null if not exists
     * @throws CacheException
     */
    public Object get(Object key) throws CacheException;

    /**
     * put an item to the cache, nontransactionally, with
     * failfast semantics
     *
     * @param key
     * @param value
     * @throws CacheException
     */
    public void put(Object key, Object value) throws CacheException;

    /**
     * update an item in the cache,if not exists ,then add it
     *
     * @param key
     * @param value
     * @throws CacheException
     */
    public void update(Object key, Object value) throws CacheException;

    /**
     * get the keys in the cache
     *
     * @return
     * @throws CacheException
     */
    @SuppressWarnings("rawtypes")
    public List keys() throws CacheException;

    /**
     * remove an item from the cache
     *
     * @param key
     * @throws CacheException
     */
    public void remove(Object key) throws CacheException;

    /**
     * Clear the cache
     */
    public void clear() throws CacheException;

    /**
     * Clean up
     */
    public void destroy() throws CacheException;

}
